using ASP;
using HoWave.Common;
using HoWave.Web;
using HoWave.Web.Admin;
using System;
using System.Data;
using System.IO;
using System.Text;
using System.Web;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
public class HL_Admin_Admin_UpdateAdZone : Admin, IRequiresSessionState
{
	protected HtmlInputText ZoneName;
	protected RequiredFieldValidator RequiredFieldValidator13;
	protected HtmlInputText ZoneJSName;
	protected RequiredFieldValidator RequiredFieldValidator14;
	protected Label Label1;
	protected HtmlTextArea ZoneIntro;
	protected RadioButtonList ZoneType;
	protected HtmlInputText Baner_Border;
	protected DropDownList Pop_PopType;
	protected HtmlInputText Pop_Left;
	protected RequiredFieldValidator RequiredFieldValidator12;
	protected RangeValidator RangeValidator12;
	protected HtmlInputText Pop_Top;
	protected RequiredFieldValidator RequiredFieldValidator11;
	protected RangeValidator RangeValidator11;
	protected HtmlInputText Pop_CookieHour;
	protected RequiredFieldValidator RequiredFieldValidator10;
	protected RangeValidator RangeValidator10;
	protected HtmlInputText Move_Left;
	protected RequiredFieldValidator RequiredFieldValidator9;
	protected RangeValidator RangeValidator9;
	protected HtmlInputText Move_Top;
	protected RequiredFieldValidator RequiredFieldValidator8;
	protected RangeValidator RangeValidator8;
	protected HtmlInputText Move_Delta;
	protected RequiredFieldValidator RequiredFieldValidator6;
	protected RangeValidator RangeValidator7;
	protected HtmlInputText Fixed_Left;
	protected RequiredFieldValidator RequiredFieldValidator5;
	protected RangeValidator RangeValidator6;
	protected HtmlInputText Fixed_Top;
	protected RequiredFieldValidator RequiredFieldValidator4;
	protected RangeValidator RangeValidator5;
	protected DropDownList Float_Type;
	protected HtmlInputText Float_Left;
	protected RequiredFieldValidator RequiredFieldValidator3;
	protected RangeValidator RangeValidator3;
	protected HtmlInputText Float_Top;
	protected RequiredFieldValidator RequiredFieldValidator2;
	protected RangeValidator RangeValidator2;
	protected HtmlInputText DropDown_ShowTime;
	protected HtmlInputText DropDown_CookieHour;
	protected RequiredFieldValidator rfv_15;
	protected RangeValidator rv_13;
	protected HtmlInputText ZoneWidth;
	protected RequiredFieldValidator RequiredFieldValidator7;
	protected RangeValidator RangeValidator4;
	protected HtmlInputText ZoneHeight;
	protected RequiredFieldValidator RequiredFieldValidator1;
	protected RangeValidator RangeValidator1;
	protected RadioButtonList ShowType;
	protected CheckBox Active;
	protected HtmlInputSubmit Submit1;
	protected HtmlInputSubmit Submit2;
	private int ZoneID = -1;
	private string myCopyRight = "//恒浪网络==By 林子：不允许修改，否则出错，谢谢！==";
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		if (!base.admin.CheckAdminPower(3))
		{
			base.WriteLog("Modidy", Language.GetAdminMsg("Log/Access", "0"), "Ads");
			base.WriteRightErrMsg();
		}
		if (base.Request.QueryString["Add"] != null)
		{
			this.Submit1.Visible = true;
			this.Submit2.Visible = false;
		}
		if (base.Request.QueryString["UpdateZoneID"] != null)
		{
			this.ZoneID = int.Parse(base.Request.QueryString["UpdateZoneID"].ToString());
			this.Submit1.Visible = false;
			this.Submit2.Visible = true;
		}
		else
		{
			this.Submit2.Visible = false;
		}
		this.ZoneType.Attributes.Add("onClick", "SelectZone('" + this.ZoneType.ClientID + "')");
		if (!base.IsPostBack)
		{
			this.ZoneJSName.Value = DateTime.Now.ToString("yyyyMM") + "/" + DateTime.Now.ToString("yyyy_MM_dd_hhmmss") + ".js";
			if (this.ZoneID > -1)
			{
				AdZoneBll adZoneBll = new AdZoneBll();
				DataRow dataRow = adZoneBll.GetSingeAdZone(this.ZoneID).Rows[0];
				this.ZoneName.Value = dataRow["ZoneName"].ToString();
				this.ZoneIntro.Value = dataRow["ZoneIntro"].ToString();
				this.ZoneJSName.Value = dataRow["ZoneJsName"].ToString();
				this.ZoneType.SelectedValue = dataRow["zonetype"].ToString();
				if (bool.Parse(dataRow["Active"].ToString()))
				{
					this.Active.Checked = true;
				}
				else
				{
					this.Active.Checked = false;
				}
				this.ShowType.SelectedValue = dataRow["showtype"].ToString();
				this.ZoneWidth.Value = dataRow["zonewidth"].ToString();
				this.ZoneHeight.Value = dataRow["zoneheight"].ToString();
				string text = dataRow["zonesetting"].ToString();
				string[] array = text.Split(new char[]
				{
					','
				});
				string selectedValue = this.ZoneType.SelectedValue;
				if (selectedValue != null)
				{
					if (!(selectedValue == "1"))
					{
						if (!(selectedValue == "2"))
						{
							if (!(selectedValue == "3"))
							{
								if (!(selectedValue == "4"))
								{
									if (!(selectedValue == "5"))
									{
										if (selectedValue == "7")
										{
											if (array.Length == 2)
											{
												this.DropDown_ShowTime.Value = array[0];
												this.DropDown_CookieHour.Value = array[1];
											}
										}
									}
									else
									{
										if (array.Length == 3)
										{
											this.Float_Left.Value = array[0];
											this.Float_Top.Value = array[1];
											this.Float_Type.SelectedValue = array[2];
										}
									}
								}
								else
								{
									if (array.Length == 2)
									{
										this.Fixed_Left.Value = array[0];
										this.Fixed_Top.Value = array[1];
									}
								}
							}
							else
							{
								if (array.Length == 3)
								{
									this.Move_Left.Value = array[0];
									this.Move_Top.Value = array[1];
									this.Move_Delta.Value = array[2];
								}
							}
						}
						else
						{
							if (array.Length == 4)
							{
								this.Pop_PopType.SelectedValue = array[0];
								this.Pop_Left.Value = array[1];
								this.Pop_Top.Value = array[2];
								this.Pop_CookieHour.Value = array[3];
							}
						}
					}
					else
					{
						if (array.Length == 1)
						{
							this.Baner_Border.Value = array[0];
						}
					}
				}
			}
		}
	}
	protected StringBuilder GetJsStrByZoneID(int ZoneID, bool NeedCreateDir, out string ZoneJsPath)
	{
		ZoneJsPath = "";
		string strZonID = ZoneID.ToString();
		AdZoneBll adZoneBll = new AdZoneBll();
		DataTable singeAdZone = adZoneBll.GetSingeAdZone(ZoneID);
		StringBuilder result = new StringBuilder();
		if (singeAdZone != null && singeAdZone.Rows.Count == 1)
		{
			DataRow dataRow = adZoneBll.GetSingeAdZone(ZoneID).Rows[0];
			int num = int.Parse(dataRow["ChannelID"].ToString());
			string text = dataRow["ZoneName"].ToString();
			string text2 = dataRow["ZoneIntro"].ToString();
			string text3 = dataRow["ZoneJsName"].ToString();
			int num2 = int.Parse(dataRow["zonetype"].ToString());
			bool flag = bool.Parse(dataRow["defaultsetting"].ToString());
			bool active = bool.Parse(dataRow["Active"].ToString());
			int showType = int.Parse(dataRow["showtype"].ToString());
			int zoneWidth = int.Parse(dataRow["zonewidth"].ToString());
			int zoneHeight = int.Parse(dataRow["zoneheight"].ToString());
			string[] array = dataRow["zonesetting"].ToString().Split(new char[]
			{
				','
			});
			ZoneJsPath = HttpContext.Current.Server.MapPath("../AD/" + text3);
			switch (num2)
			{
			case 1:
				result = this.BannerZoneAD(strZonID, zoneWidth, zoneHeight, showType, active, this.Baner_Border.Value);
				break;
			case 2:
			{
				int pop_PopType = int.Parse(array[0]);
				int pop_Left = int.Parse(array[1]);
				int pop_Top = int.Parse(array[2]);
				int pop_CookieHour = int.Parse(array[3]);
				result = this.PopZoneAD(strZonID, zoneWidth, zoneHeight, showType, pop_PopType, pop_Left, pop_Top, pop_CookieHour, active);
				break;
			}
			case 3:
			{
				int move_Left = int.Parse(array[0]);
				int move_Top = int.Parse(array[1]);
				string move_Delta = array[2].Trim();
				result = this.MoveZoneAD(strZonID, zoneWidth, zoneHeight, showType, move_Left, move_Top, move_Delta, active);
				break;
			}
			case 4:
			{
				int fixed_Left = int.Parse(array[0]);
				int fiexed_Top = int.Parse(array[1]);
				result = this.FixedZoneAD(strZonID, zoneWidth, zoneHeight, showType, fixed_Left, fiexed_Top, active);
				break;
			}
			case 5:
			{
				int float_Left = int.Parse(array[0]);
				int float_Top = int.Parse(array[1]);
				int float_Type = int.Parse(array[2]);
				result = this.FloatZoneAD(strZonID, zoneWidth, zoneHeight, showType, float_Left, float_Top, float_Type, active);
				break;
			}
			case 6:
				result = this.CodeZoneAD(strZonID, zoneWidth, zoneHeight, showType, active);
				break;
			case 7:
			{
				int showTime = int.Parse(this.DropDown_ShowTime.Value);
				result = this.DropDownAD(strZonID, zoneWidth, zoneHeight, showType, active, showTime, int.Parse(this.DropDown_CookieHour.Value));
				break;
			}
			}
			if (NeedCreateDir)
			{
				try
				{
					int num3 = text3.LastIndexOf("/");
					if (num3 > -1)
					{
						string path = HttpContext.Current.Server.MapPath("..") + "\\AD\\" + text3.Substring(0, num3);
						if (!Directory.Exists(path))
						{
							Directory.CreateDirectory(path);
						}
					}
				}
				catch (Exception ex)
				{
					this.WriteErrMsg("生成广告JS文件夹出错", ex.Message, "");
				}
			}
		}
		return result;
	}
	private void Createjs(int ZoneID)
	{
		string text = "";
		StringBuilder jsStrByZoneID = this.GetJsStrByZoneID(ZoneID, true, out text);
		if (text != "" && File.Exists(text))
		{
			File.Delete(text);
		}
		jsStrByZoneID.Append("\n" + this.myCopyRight + "\n");
		this.InsertJs(text, jsStrByZoneID);
	}
	protected void Updatejs(int ZoneID)
	{
		string text = "";
		StringBuilder jsStrByZoneID = this.GetJsStrByZoneID(ZoneID, true, out text);
		if (text == "" || !File.Exists(text))
		{
			this.Createjs(ZoneID);
		}
		else
		{
			StringBuilder stringBuilder = this.ReadJsTemplate(text);
			string value;
			if (stringBuilder.ToString().Contains(this.myCopyRight))
			{
				value = stringBuilder.Remove(0, stringBuilder.ToString().IndexOf(this.myCopyRight)).ToString();
			}
			else
			{
				value = "\n" + this.myCopyRight + "\n";
			}
			jsStrByZoneID.Insert(jsStrByZoneID.Length, value);
			this.InsertJs(text, jsStrByZoneID);
			this.Label1.Text = "";
		}
	}
	protected void Submit1_ServerClick(object sender, EventArgs e)
	{
		if (base.IsValid)
		{
			string setting = this.GetSetting();
			bool active = false;
			bool dafaultSetting = false;
			if (this.Active.Checked)
			{
				active = true;
			}
			AdZoneBll adZoneBll = new AdZoneBll();
			int zoneID = adZoneBll.InnerAdZone(0, this.ZoneName.Value, this.ZoneJSName.Value, this.ZoneIntro.Value, int.Parse(this.ZoneType.SelectedValue), dafaultSetting, setting, int.Parse(this.ZoneWidth.Value), int.Parse(this.ZoneHeight.Value), active, int.Parse(this.ShowType.SelectedValue), DateTime.Now.Date);
			this.Createjs(zoneID);
			this.ZoneJSName.Value = string.Concat(new string[]
			{
				DateTime.Now.ToString("yyyyMM"),
				"/",
				DateTime.Now.ToString("ddhhmmss"),
				DateTime.Now.Millisecond.ToString(),
				".js"
			});
			base.Response.Write("<script language='javascript'>alert('添加成功')</script>");
			base.Response.Write("<script language='javascript'>location.href='Admin_Manageadzone.aspx'</script>");
		}
	}
	private string GetSetting()
	{
		string text = "";
		string selectedValue = this.ZoneType.SelectedValue;
		if (selectedValue != null)
		{
			if (!(selectedValue == "1"))
			{
				if (!(selectedValue == "2"))
				{
					if (!(selectedValue == "3"))
					{
						if (!(selectedValue == "4"))
						{
							if (!(selectedValue == "5"))
							{
								if (selectedValue == "7")
								{
									text = text + this.DropDown_ShowTime.Value + "," + this.DropDown_CookieHour.Value;
								}
							}
							else
							{
								string text2 = text;
								text = string.Concat(new string[]
								{
									text2,
									this.Float_Left.Value,
									",",
									this.Float_Top.Value,
									",",
									this.Float_Type.SelectedValue
								});
							}
						}
						else
						{
							text = text + this.Fixed_Left.Value + "," + this.Fixed_Top.Value;
						}
					}
					else
					{
						string text2 = text;
						text = string.Concat(new string[]
						{
							text2,
							this.Move_Left.Value,
							",",
							this.Move_Top.Value,
							",",
							this.Move_Delta.Value
						});
					}
				}
				else
				{
					string text2 = text;
					text = string.Concat(new string[]
					{
						text2,
						this.Pop_PopType.SelectedValue,
						",",
						this.Pop_Left.Value,
						",",
						this.Pop_Top.Value,
						",",
						this.Pop_CookieHour.Value
					});
				}
			}
			else
			{
				text += this.Baner_Border.Value;
			}
		}
		return text;
	}
	protected void Submit2_ServerClick(object sender, EventArgs e)
	{
		if (base.IsValid)
		{
			string setting = this.GetSetting();
			bool active = false;
			if (this.Active.Checked)
			{
				active = true;
			}
			bool dafaultSetting = false;
			AdZoneBll adZoneBll = new AdZoneBll();
			adZoneBll.UpdateAdZone(0, this.ZoneName.Value, this.ZoneJSName.Value, this.ZoneIntro.Value, int.Parse(this.ZoneType.SelectedValue), dafaultSetting, setting, int.Parse(this.ZoneWidth.Value), int.Parse(this.ZoneHeight.Value), active, int.Parse(this.ShowType.SelectedValue), DateTime.Now.Date, this.ZoneID);
			this.Updatejs(this.ZoneID);
			base.Response.Write("<script language='javascript'>alert('修改成功!')</script>");
			base.Response.Write("<script language='javascript'>location.href='Admin_Manageadzone.aspx'</script>");
		}
	}
	private StringBuilder BannerZoneAD(string strZonID, int ZoneWidth, int ZoneHeight, int ShowType, bool m_Active, string BorderWidth)
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder = this.ReadJsTemplate("Template_Banner", false);
		StringBuilder result;
		try
		{
			stringBuilder.Insert(stringBuilder.Length, string.Concat(new string[]
			{
				"    var ZoneAD_",
				strZonID,
				" = new BannerZoneAD(\"ZoneAD_",
				strZonID,
				"\");\r\nZoneAD_",
				strZonID,
				".ZoneID      = ",
				strZonID,
				";\r\nZoneAD_",
				strZonID,
				".ZoneWidth   = ",
				ZoneWidth.ToString(),
				";\r\nZoneAD_",
				strZonID,
				".ZoneHeight  = ",
				ZoneHeight.ToString(),
				";\r\nZoneAD_",
				strZonID,
				".Border       = ",
				BorderWidth,
				";\r\nZoneAD_",
				strZonID,
				".zoneActive  = \"",
				m_Active.ToString(),
				"\";\r\nZoneAD_",
				strZonID,
				".ShowType    = ",
				ShowType.ToString(),
				";\r\n"
			}));
			result = stringBuilder;
		}
		catch (Exception ex)
		{
			base.Response.Write(ex.ToString());
			result = null;
		}
		return result;
	}
	private StringBuilder PopZoneAD(string strZonID, int ZoneWidth, int ZoneHeight, int ShowType, int Pop_PopType, int Pop_Left, int Pop_Top, int Pop_CookieHour, bool m_Active)
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder = this.ReadJsTemplate("Template_Pop", false);
		StringBuilder result;
		try
		{
			stringBuilder.Insert(stringBuilder.Length, string.Concat(new string[]
			{
				"    var ZoneAD_",
				strZonID,
				" = new PopZoneAD(\"ZoneAD_",
				strZonID,
				"\");\r\nZoneAD_",
				strZonID,
				".ZoneID      = ",
				strZonID,
				";\r\nZoneAD_",
				strZonID,
				".ZoneWidth   =",
				ZoneWidth.ToString(),
				";\r\nZoneAD_",
				strZonID,
				".ZoneHeight  = ",
				ZoneHeight.ToString(),
				";\r\nZoneAD_",
				strZonID,
				".ShowType    =",
				ShowType.ToString(),
				";\r\nZoneAD_",
				strZonID,
				".PopType    =",
				Pop_PopType.ToString(),
				";\r\nZoneAD_",
				strZonID,
				".Left    =",
				Pop_Left.ToString(),
				";\r\nZoneAD_",
				strZonID,
				".Top    =",
				Pop_Top.ToString(),
				";\r\nZoneAD_",
				strZonID,
				".CookieHour    =",
				Pop_CookieHour.ToString(),
				";\r\nZoneAD_",
				strZonID,
				".zoneActive    =\"",
				m_Active.ToString(),
				"\";\r\n"
			}));
			result = stringBuilder;
		}
		catch (Exception ex)
		{
			base.Response.Write(ex.ToString());
			result = null;
		}
		return result;
	}
	private StringBuilder MoveZoneAD(string strZonID, int ZoneWidth, int ZoneHeight, int ShowType, int Move_Left, int Move_Top, string Move_Delta, bool m_Active)
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder = this.ReadJsTemplate("Template_Move", false);
		StringBuilder result;
		try
		{
			stringBuilder.Insert(stringBuilder.Length, string.Concat(new string[]
			{
				"    var ZoneAD_",
				strZonID,
				" = new  MoveZoneAD(\"ZoneAD_",
				strZonID,
				"\");\r\nZoneAD_",
				strZonID,
				".ZoneID      = ",
				strZonID,
				";\r\nZoneAD_",
				strZonID,
				".ZoneWidth   =",
				ZoneWidth.ToString(),
				";\r\nZoneAD_",
				strZonID,
				".ZoneHeight  = ",
				ZoneHeight.ToString(),
				";\r\nZoneAD_",
				strZonID,
				".ShowType    =",
				ShowType.ToString(),
				";\r\nZoneAD_",
				strZonID,
				".Left    =",
				Move_Left.ToString(),
				";\r\nZoneAD_",
				strZonID,
				".Top    =",
				Move_Top.ToString(),
				";\r\nZoneAD_",
				strZonID,
				".Delta    =",
				Move_Delta.ToString(),
				";\r\nZoneAD_",
				strZonID,
				".zoneActive    =\"",
				m_Active.ToString(),
				"\";\r\n"
			}));
			result = stringBuilder;
		}
		catch (Exception ex)
		{
			base.Response.Write(ex.ToString());
			result = null;
		}
		return result;
	}
	private StringBuilder FixedZoneAD(string strZonID, int ZoneWidth, int ZoneHeight, int ShowType, int Fixed_Left, int Fiexed_Top, bool m_Active)
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder = this.ReadJsTemplate("Template_Fixed", false);
		StringBuilder result;
		try
		{
			stringBuilder.Insert(stringBuilder.Length, string.Concat(new string[]
			{
				"    var ZoneAD_",
				strZonID,
				" = new FixedZoneAD(\"ZoneAD_",
				strZonID,
				"\");\r\nZoneAD_",
				strZonID,
				".ZoneID      = ",
				strZonID,
				";\r\nZoneAD_",
				strZonID,
				".ZoneWidth   =",
				ZoneWidth.ToString(),
				";\r\nZoneAD_",
				strZonID,
				".ZoneHeight  = ",
				ZoneHeight.ToString(),
				";\r\nZoneAD_",
				strZonID,
				".ShowType    =",
				ShowType.ToString(),
				";\r\nZoneAD_",
				strZonID,
				".Left    =",
				Fixed_Left.ToString(),
				";\r\nZoneAD_",
				strZonID,
				".zoneActive    =\"",
				m_Active.ToString(),
				"\";\r\nZoneAD_",
				strZonID,
				".Top    =",
				Fiexed_Top.ToString(),
				";\r\n"
			}));
			result = stringBuilder;
		}
		catch (Exception ex)
		{
			base.Response.Write(ex.ToString());
			result = null;
		}
		return result;
	}
	private StringBuilder FloatZoneAD(string strZonID, int ZoneWidth, int ZoneHeight, int ShowType, int Float_Left, int Float_Top, int Float_Type, bool m_Active)
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder = this.ReadJsTemplate("Template_Float", false);
		StringBuilder result;
		try
		{
			stringBuilder.Insert(stringBuilder.Length, string.Concat(new string[]
			{
				"    var ZoneAD_",
				strZonID,
				" = new FloatZoneAD(\"ZoneAD_",
				strZonID,
				"\");\r\nZoneAD_",
				strZonID,
				".ZoneID      = ",
				strZonID,
				";\r\nZoneAD_",
				strZonID,
				".ZoneWidth   =",
				ZoneWidth.ToString(),
				";\r\nZoneAD_",
				strZonID,
				".ZoneHeight  = ",
				ZoneHeight.ToString(),
				";\r\nZoneAD_",
				strZonID,
				".ShowType    =",
				ShowType.ToString(),
				";\r\nZoneAD_",
				strZonID,
				".FloatType    =",
				Float_Type.ToString(),
				";\r\nZoneAD_",
				strZonID,
				".Left    =",
				Float_Left.ToString(),
				";\r\nZoneAD_",
				strZonID,
				".zoneActive    =\"",
				m_Active.ToString(),
				"\";\r\nZoneAD_",
				strZonID,
				".Top    =",
				Float_Top.ToString(),
				";\r\n"
			}));
			result = stringBuilder;
		}
		catch (Exception ex)
		{
			base.Response.Write(ex.ToString());
			result = null;
		}
		return result;
	}
	private StringBuilder CodeZoneAD(string strZonID, int ZoneWidth, int ZoneHeight, int ShowType, bool m_Active)
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder = this.ReadJsTemplate("Template_Code", false);
		StringBuilder result;
		try
		{
			stringBuilder.Insert(stringBuilder.Length, string.Concat(new string[]
			{
				"    var ZoneAD_",
				strZonID,
				" = new CodeZoneAD(\"ZoneAD_",
				strZonID,
				"\");\r\nZoneAD_",
				strZonID,
				".ZoneID      = ",
				strZonID,
				";\r\nZoneAD_",
				strZonID,
				".ZoneWidth   =",
				ZoneWidth.ToString(),
				";\r\nZoneAD_",
				strZonID,
				".ZoneHeight  = ",
				ZoneHeight.ToString(),
				";\r\nZoneAD_",
				strZonID,
				".zoneActive  = \"",
				m_Active.ToString(),
				"\";\r\nZoneAD_",
				strZonID,
				".ShowType    =",
				ShowType.ToString(),
				";\r\n"
			}));
			result = stringBuilder;
		}
		catch (Exception ex)
		{
			base.Response.Write(ex.ToString());
			result = null;
		}
		return result;
	}
	private StringBuilder DropDownAD(string strZonID, int ZoneWidth, int ZoneHeight, int ShowType, bool m_Active, int ShowTime, int CookieHour)
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder = this.ReadJsTemplate("Template_DropDown", false);
		StringBuilder result;
		try
		{
			stringBuilder.Insert(stringBuilder.Length, string.Concat(new string[]
			{
				"    var ZoneAD_",
				strZonID,
				" = new DropDownZoneAD(\"ZoneAD_",
				strZonID,
				"\");\r\nZoneAD_",
				strZonID,
				".ZoneID      = ",
				strZonID,
				";\r\nZoneAD_",
				strZonID,
				".ZoneWidth   =",
				ZoneWidth.ToString(),
				";\r\nZoneAD_",
				strZonID,
				".ZoneHeight  = ",
				ZoneHeight.ToString(),
				";\r\nZoneAD_",
				strZonID,
				".zoneActive  = \"",
				m_Active.ToString(),
				"\";\r\nZoneAD_",
				strZonID,
				".ShowTime    = ",
				ShowTime.ToString(),
				";\r\nZoneAD_",
				strZonID,
				".CookieHour  =",
				CookieHour.ToString(),
				";\r\nZoneAD_",
				strZonID,
				".ShowType    =",
				ShowType.ToString(),
				";\r\n"
			}));
			result = stringBuilder;
		}
		catch (Exception ex)
		{
			base.Response.Write(ex.ToString());
			result = null;
		}
		return result;
	}
	private StringBuilder ReadJsTemplate(string JsName, bool IsPhysicalPath)
	{
		string path = JsName;
		if (!IsPhysicalPath)
		{
			path = HttpContext.Current.Server.MapPath("..") + "\\AD\\ADTemplate\\" + JsName + ".js";
		}
		StringBuilder stringBuilder = new StringBuilder();
		StringBuilder result;
		try
		{
			using (StreamReader streamReader = new StreamReader(path, Encoding.Default))
			{
				string str;
				while ((str = streamReader.ReadLine()) != null)
				{
					stringBuilder.Append(str + "\r\n");
				}
				streamReader.Close();
				result = stringBuilder;
			}
		}
		catch (Exception ex)
		{
			base.Response.Write(ex.ToString());
			result = null;
		}
		return result;
	}
	private StringBuilder ReadJsTemplate(string JsPath)
	{
		return this.ReadJsTemplate(JsPath, true);
	}
	private void InsertJs(string strFileName, StringBuilder strjs)
	{
		FileInfo fileInfo = new FileInfo(strFileName);
		if (!fileInfo.Directory.Exists)
		{
			try
			{
				fileInfo.Directory.Create();
			}
			catch
			{
				base.Response.Write("无法创建目录！");
				base.Response.End();
			}
		}
		try
		{
			using (StreamWriter streamWriter = new StreamWriter(strFileName, false, Encoding.GetEncoding("GB2312")))
			{
				streamWriter.WriteLine(strjs);
				streamWriter.Flush();
				streamWriter.Close();
			}
		}
		catch (Exception ex)
		{
			base.Response.Write(ex.ToString());
		}
	}
}
